package com.bjsxt.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bjsxt.pojo.HostAddResult;
import com.bjsxt.pojo.PageResult;
import com.bjsxt.pojo.Role;
import com.bjsxt.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-10-14
 */
@Controller
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private IRoleService roleService;
    //查询所有角色
    @ResponseBody
    @RequestMapping("roleInfo")
    public PageResult<Role> roleInfo(Integer page,Integer rows){
        IPage<Role> iPage = new Page<>(page,rows);
        PageResult<Role> pageResult = roleService.selRoleInfo(page,rows);
        return pageResult;
    }

    //查询所有角色
    @ResponseBody
    @RequestMapping("roleAdd")
    public HostAddResult roleAdd(Role role, String mids){
        //处理请求
        HostAddResult hostAddResult = roleService.insRoleInfoService(role,mids);

        return hostAddResult;
    }

    //更新角色
    @ResponseBody
    @RequestMapping("roleEdit")
    public HostAddResult roleEdit(Role role, String mids){
        //处理请求
        HostAddResult hostAddResult = roleService.upRoleInfoService(role,mids);

        return hostAddResult;
    }

    //删除角色
    @ResponseBody
    @RequestMapping("roleDel")
    public HostAddResult roleDel(String rids){
        //处理请求
        HostAddResult hostAddResult = roleService.delRoleInfoService(rids);

        return hostAddResult;
    }
}

